home *** CD-ROM | disk | FTP | other *** search
/ The PC-SIG Library 10 / The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso / PC_SIGCD / 22 / 4 / DISK2247.ZIP / CBASE101.ZIP / CBASE.ZIP / CBRECNEX.C < prev    next >
Text File  |  1990-06-21  |  2KB  |  74 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)cbrecnex.c    1.4 - 90/06/20" */
  5.  
  6. /* ansi headers */
  7. #include <errno.h>
  8.  
  9. /* library headers */
  10. #include <lseq.h>
  11.  
  12. /* local headers */
  13. #include "cbase_.h"
  14.  
  15. /*man---------------------------------------------------------------------------
  16. NAME
  17.      cbrecnext - next cbase record
  18.  
  19. SYNOPSIS
  20.      #include <cbase.h>
  21.  
  22.      int cbrecnext(cbp)
  23.      cbase_t *cbp;
  24.  
  25. DESCRIPTION
  26.      The cbrecnext function advances the record cursor of cbase cbp to
  27.      the next record.  If the cursor is on the last record, it is
  28.      advanced to null.
  29.  
  30.      cbrecnext will fail if one or more of the following is true:
  31.  
  32.      [EINVAL]       cbp is not a valid cbase pointer.
  33.      [CBELOCK]      cbp is not locked.
  34.      [CBENOPEN]     cbp is not open.
  35.  
  36. SEE ALSO
  37.      cbrcursor, cbrecfirst, cbreclast, cbrecprev.
  38.  
  39. DIAGNOSTICS
  40.      Upon successful completion, a value of 0 is returned.  Otherwise,
  41.      a value of -1 is returned, and errno set to indicate the error.
  42.  
  43. ------------------------------------------------------------------------------*/
  44. int cbrecnext(cbp)
  45. cbase_t *cbp;
  46. {
  47.     /* validate arguments */
  48.     if (!cb_valid(cbp)) {
  49.         errno = EINVAL;
  50.         return -1;
  51.     }
  52.  
  53.     /* check if not open */
  54.     if (!(cbp->flags & CBOPEN)) {
  55.         errno = CBENOPEN;
  56.         return -1;
  57.     }
  58.  
  59.     /* check if not locked */
  60.     if (!(cbp->flags & CBLOCKS)) {
  61.         errno = CBELOCK;
  62.         return -1;
  63.     }
  64.  
  65.     /* advance cursor to next record */
  66.     if (lsnext(cbp->lsp) == -1) {
  67.         CBEPRINT;
  68.         return -1;
  69.     }
  70.  
  71.     errno = 0;
  72.     return 0;
  73. }
  74.